// 计算日期的个位数和星期重合的case

#include <iostream>
#define isLeap(year) ((0==year%400) ? true :((0==year%100) ? false : ((0==year%4) ? true : false)))

using namespace std;
int main()
{
	int week=4;// 2015-1-1 is thurseday
	int matchCount = 0;
	int loopCount = 0;
	for(int year=2015; year<2061; ++year){
		for(int month=1; month<=12; ++month) {

			int daysInMonth = 31;
			if(4 == month || 6 == month || 9==month || 11==month){
				daysInMonth = 30;
			} else if(2 == month) {
				if(isLeap(year)) {
					daysInMonth = 29;
				}else {
					daysInMonth = 28;
				}
			}
			
			for(int day=1; day<=daysInMonth; ++day){
				if(day%10 == week && day < 30){
					++matchCount;
					cout<<"date:"<<year<<"-"<<month<<"-"<<day<<", week"<<week<<endl;
				}
				++week;
				if(week >7){
					week = 1;
				}
				++loopCount;
			}// end of for(day)
		}// end of for(month)
	}// end of for(year)

	cout<<"loop count "<<loopCount<<", matchCount "<<matchCount<<endl;
	return 0;
}
